﻿using System;
using System.Linq;
using System.Linq.Expressions;
using System.Threading.Tasks;
using ZSoft.Telegram.DataAccess.Abstraction;

namespace ZSoft.Telegram.DataAccess.Abstractions
{
    public interface IRepository<T> where T : class, IEntity
    {
        IRepository<T> Add(T item);
        IRepository<T> Remove(T item);
        IRepository<T> Update(T item);
        IRepository<T> Attach(T item);
        Task<int> JustDeleteAsync(Expression<Func<T, bool>> predicate);
        int Update(Expression<Func<T, bool>> predicate, Expression<Func<T, T>> updateExpression);
        Task<int> UpdateAsync(Expression<Func<T, bool>> predicate, Expression<Func<T, T>> updateExpression);
        IRepository<TEntity> GetTypeRepository<TEntity>() where TEntity : class, IEntity;
        IQueryable<T> All();
        T First(params string[] includes);
        Task<T> FirstAsync(string[] includes);
        T First(Func<T, bool> predicate, params string[] includes);
        T FirstOrDefault(Func<T, bool> predicate, params string[] includes);
        Task<T> FirstAsync(Expression<Func<T, bool>> predicate, params string[] includes);
        IQueryable<T> Where(Expression<Func<T, bool>> predicate, params string[] includes);
        bool Any(Func<T, bool> predicate);
        Task<bool> AnyAsync(Expression<Func<T, bool>> predicate);
        Task<int> SaveChangesAsync();
        int SaveChanges();
    }
}
